﻿using System;
using System.Data;
using System.Collections.Generic;

using System.Text;
using KPIS.GERP.ESS.MODEL;
using KPIS.GERP.ESS.DAL;

namespace KPIS.GERP.ESS.BLL
{
    public class B_MessageReply
    {
        ConvertNullable.ConvertNullable cn = new ConvertNullable.ConvertNullable();
        private static readonly D_MessageReply dal = new D_MessageReply();
        //D_FIM_MAS_Receives r = new D_FIM_MAS_Receives();

        public B_MessageReply()
        {

        }

        public List<M_MessageReply> GetFull(string to_user_seq
            , string from_user_seq, string message_status)
        {
            Nullable<int> nto_user_seq = cn.ConvertNullInt(to_user_seq);
            Nullable<int> nfrom_user_seq = cn.ConvertNullInt(from_user_seq);
            return dal.GetFull(nto_user_seq, nfrom_user_seq, message_status);
        }

        public List<M_MessageReply> GetList(string to_user_seq
            , string from_user_seq, string message_status)
        {
            Nullable<int> nto_user_seq = cn.ConvertNullInt(to_user_seq);
            Nullable<int> nfrom_user_seq = cn.ConvertNullInt(from_user_seq);
            return dal.GetList(nto_user_seq, nfrom_user_seq, message_status);
        }

        //public string SelectRecentInsertedRoleSeq()
        //{
        //    return dal.SelectRecentInsertedRoleSeq();
        //}

        public M_MessageReply GetInfo(string seq)
        {
            int nSeq;
 
            if (seq == null)
                return null;

            if (cn.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public List<M_MessageReply> GetInfoFromRefSeq(string seq, string ref_type)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (cn.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfoFromRefSeq(nSeq, ref_type);
            }
            else
            {
                return null;
            }
        }

        public M_MessageReply GetInfoFromSendSeq(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (cn.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfoFromSendSeq(nSeq);
            }
            else
            {
                return null;
            }
        }

        public string Insert(M_MessageReply info)
        {
            try
            {
                return dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_MessageReply info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_MessageReply info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }

        public void UpdateMessageStatus(M_MessageReply info)
        {
            try
            {
                dal.UpdateMessageStatus(info);
            }
            catch
            {
                throw;
            }
        }

        public IList<M_MessageReply> GetInfoFromMoneyReqSeq(string seq)
        {
            return dal.GetInfoFromMoneyReqSeq(cn.ConvertNullInt(seq).Value);
        }
    }
}
